package com.linkhub.oms.dao.mpservice.impl;

import com.linkhub.oms.common.enums.mp.DataSyncTypeEnum;
import com.linkhub.oms.entity.DataSyncRecordEntity;
import com.linkhub.oms.dao.mapper.DataSyncRecordEntityMapper;
import com.linkhub.oms.dao.mpservice.IDataSyncRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 拉取记录表 服务实现类
 * </p>
 *
 * @author echo
 * @since 2024-03-20
 */
@Service
public class DataSyncRecordServiceImpl extends ServiceImpl<DataSyncRecordEntityMapper, DataSyncRecordEntity> implements IDataSyncRecordService {

    @Override
    public DataSyncRecordEntity queryLatestSyncRecord(String sysShopId, DataSyncTypeEnum syncType) {
        return lambdaQuery()
                .eq(DataSyncRecordEntity::getSysShopId, sysShopId)
                .eq(DataSyncRecordEntity::getType, syncType)
                .orderByDesc(DataSyncRecordEntity::getId)
                .last("LIMIT 1")
                .one();
    }
}
